<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>SMap test</title>
</head>

<script type="text/javascript" src="../smap.js"></script>
<script type="text/javascript" src="js/testUnit.js"></script>
<body>

<script>
	title('Bounds class');
	test('b = new Bounds()');
	test('b.left', 0);
	test('b.top', 0);
	test('b.right', 0);
	test('b.bottom', 0);
	test('b.left = 10', 10);
	test('b.bottom = 40', 40);
	test('b.right = 20', 20);
	test('b.top = -20', -20);
	test('b.getWidth()', 10);
	test('b.getHeight()', 60);
	test('b.getCenterLonLat().toString()', new LonLat(15, 10));
	test('b.getCenterXY().toArray()[0]', 15);
	test('b.getCenterXY().toArray()[1]', 10);
	test('b.containsXY((new XY()).fromArray([15, 10]))', true);
	test('b.toArray()');
	test('b.clone().toArray()[0]', 10);
	test('b.clone().toArray()[1]', 40);
	test('b.clone().toArray()[2]', 20);
	test('b.clone().toArray()[3]', -20);
	
	title('XY class');
	test('xy = new XY()');
	test('xy.x', 0);
	test('xy.y', 0);
	test('xy.x = 10', 10);
	test('xy.y = 20', 20);
	test('xy.ensureWithin(new Bounds(0, 0, 10, 20))', true);
	test('xy.ensureWithin(new Bounds(0, 0, 5, 10))', false);
	test('xy.x', 5);
	test('xy.y', 10);
	test('xy.ensureWithin(new Bounds(10, 20, 5, 10))', true);
	test('xy.x', 5);
	test('xy.y', 10);
	test('xy.ensureWithin(new Bounds(10, 20, 20, 40))', false);
	test('xy.x', 10);
	test('xy.y', 20);
	test('xy.equal(new XY(10,20))', true);
	test('xy.equal(new XY(9.9,19.9), 0.11)', true);
	test('xy.equal(new XY(9.9,19.9))', false);
	
	title('LonLat class');
	test('ll = new LonLat()');
	test('ll.lon', 0);
	test('ll.lat', 0);
	test('ll.lon = 0.1', 0.1);
	test('ll.lat = 0.5', 0.5);
	test('ll.ensureWithin(new Bounds(0, 0, 1, 1))', true);
	test('ll.ensureWithin(new Bounds(0.5, 0.2, 1, 1))', false);
	test('ll.lon = 0.5', 0.5);
	test('ll.lat = 0.2', 0.2);
	test('ll.clone() == ll', false);
	test('ll.clone().equal(ll)', true);
	title('END');
</script>
</body>
</html>